var events = require('events');
var fs = require('fs');

var eventEmitter = new events.EventEmitter();

eventEmitter.on('customEvent', (par1, par2) => {
	let sum = 0;
	for(let i = 0 ; i < 10000; i++){
		sum += i;
	}
	console.log('customEvent has been trigger', sum, par1, par2);
})

eventEmitter.addListener('customEvent', (par1, par2)=>{
	console.log('second observer', par1, par2)
})

eventEmitter.emit('customEvent', 'first par', 'second par');



fs.readFile('../file/text.txt', (err,data)=>{
	console.log(data.toString())
})

// 创建一个可读流
var readerStream = fs.createReadStream('../file/text.txt');

// 创建一个可写流
var writerStream = fs.createWriteStream('../file/text1.txt');

// 管道读写操作
// 读取 input.txt 文件内容，并将内容写入到 output.txt 文件中
readerStream.pipe(writerStream);


console.log('over')